/**
 * @description 微博 service
 * @author hzx */
const { Op } = require("sequelize");
const { Example } = require('../db/model/Example.js')

async function _get({id}) {
    let query = { id};
    for (let i in query){
        if(!query[i]){
            delete query[i]
        }

    }
    const result = await Example.findAndCountAll({
        where: query,
        // include: [{model: Category},{model: Tag}],
        // order:[
        //     ['createdAt', timeOrder]
        // ],
        // limit:parseInt(pageSize),
        // offset: parseInt(pageSize * (pageNum -1))
    })
    return result
}
async function _add({id,params}) {
    const result = await Example.create({id,params})
    return result
}
async function _update({id,params}) {
    const query = {params}
    for(let i in query){
         if(!query[i]){
              delete query[i]
         }
     }
    const result = await Example.update(query,{
        where:{id}
    })
    return result
}
async function _remove({ id }) {
    const result = await Example.destroy({
        where:{id}
    })
    return result
}

module.exports = {
    _get,
    _add,
    _update,
    _remove,
}
